package model;

/**
 *
 * @author Dustin
 */
public class Table {
    public final static int TABLE_SIZE = 4;
    public final static int AMOUNT_OF_TABLE_CARDS = 4;

    public boolean[] hasChanged = {false, false, false, false};
    private String name;
    private Deck deck = new Deck();    
    private Card[] cards = new Card[AMOUNT_OF_TABLE_CARDS];

    /**
     * Constructs a new Table with given name
     * @param aName
     */
    public Table(String aName) {
        name = aName;
    }    

    public String getName() {
        return name;
    }

    public Deck getDeck() {
        return deck;
    }
    
    public Card getCard(int index) {
        return cards[index];
    }

    public Card[] getCards() {
        Card[] openCards = {cards[0], cards[1], cards[2]};
        return openCards;
    }

    public void setName(String aName) {
        name = aName;
    }

    public void setCard(int index, Card c) {
        if(cards[index] != c)
        {
            for(int i = 0; i < TABLE_SIZE; i++) {
                hasChanged[i] = true;
            }
        }
        cards[index] = c;
    }

    public void resetCards() {
        for(int i = 0; i < AMOUNT_OF_TABLE_CARDS; i++) {
            cards[i] = null;
        }
    }
}
